package com.world.rickcloudendpoint.service.runner;

import com.world.rickcloudendpoint.service.net.tcp.client.TransmissionClient;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @description: 传送信号客户端
 * @author: jlsong
 * @date: 2021/12/12 11:44:01
 * @version: 1.0
 */
@Component
@Order(2)
public class TransmissionClientRunner implements CommandLineRunner {
    final TransmissionClient client;

    public TransmissionClientRunner(TransmissionClient client) {
        this.client = client;
    }

    ExecutorService pool = new ThreadPoolExecutor(1, 1, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());

    @Override
    public void run(String... args) throws Exception {
        pool.execute(() -> client.start());
    }
}
